package Test;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import Controller.CtrlAppli;
import Controller.CtrlMonde;
import Modele.Case;
import Modele.Eclaireur;
import Modele.EtatEclaireuse;
import Modele.EtatOuvriere;
import Modele.EtatReine;
import Modele.Fourmi;
import Modele.Fourmiliere;
import Modele.Monde;
import Modele.Ouvrier;
import Modele.Position;
import Modele.Reine;
import PathFinding.Map;
import PathFinding.Node;
import PathFinding.NodeList;

public class testFourmiz {
	public CtrlAppli ctrlAppli;
	public CtrlMonde ctrMonde;
	public Monde monde;
	public Eclaireur ecl;
	public Fourmiliere fourm;
	public Ouvrier ouvr;
	public Reine reine;

	@Before
	public void setUp() throws Exception {
		monde = new Monde(3,3);
		Case case00 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(0, 0,case00);
		Case case01 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(0, 1,case01);
		Case case02 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(0, 1,case02);
		Case case10 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(1,0 ,case10);
		Case case11 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(1, 1,case11);
		Case case12 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(1,2,case12);
		Case case20 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(2,0,case20);
		Case case21 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(2,1,case21);
		Case case22 = new Case(0, 0,null, 0,monde);
		monde.setCaseAtPosition(2,2,case22);
		fourm = new Fourmiliere(0, this.monde,"FourmTest",0,0,20);
		ecl = new Eclaireur(EtatEclaireuse.RECHERCHENOURRITURE);
		ecl.setHome(fourm);
		ouvr = new Ouvrier(EtatOuvriere.RECHERCHEPHEROMONE);
		ouvr.setHome(fourm);
		reine = new Reine(fourm,EtatReine.CREATIONFOURMIS);
		
		ctrlAppli = new CtrlAppli();
		ctrMonde = new CtrlMonde(monde,ctrlAppli);
	}

	@After
	public void tearDown() throws Exception {
		monde=null;
	}

	@Test
	public void testCreationMonde() {
		assertNotNull(monde);
	}
	
	@Test
	public void testCreationFourmis() {
		assertNotNull(ecl);
		assertNotNull(reine);
		assertNotNull(ouvr);
	}
	
	@Test
	public void testCreationFourmiliere() {
		assertNotNull(fourm);
	}
	
	@Test
	public void testPlacerFourmis() {
		ArrayList<Fourmi> listFourmi = new ArrayList<Fourmi>();
		listFourmi.add(ecl);
		listFourmi.add(ouvr);
		listFourmi.add(reine);
		
		Case maCase00 = new Case(0, 0,listFourmi, 0,monde);
		monde.setCaseAtPosition(0,0, maCase00);
		assertEquals(3,monde.getCaseFromPosition(new Position(0, 0)).getFourmi().size());
	}
	
	@Test
	public void testPlacerFourmiliere() {
		monde.setCaseAtPosition(0, 2,fourm);
		assertEquals(Fourmiliere.class,monde.getCaseFromPosition(new Position(0,2)).getClass());
	}


	

	

}
